From e90663fd5a24e6656db72c4a1bb78aef77347d1f Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 17 Jun 2006 21:28:49 +0000 Subject: [PATCH] Add functions strupper and strlower. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2158 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/defs.h | 2 ++ gpsbabel/util.c | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 4a0aff699..e7b23d481 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -661,6 +661,8 @@ char *xstrrstr(const char *s1, const char *s2); void rtrim(char *s); char * lrtrim(char *s); int xasprintf(char **strp, const char *fmt, ...); +char *strupper(char *src); +char *strlower(char *src); signed int get_tz_offset(void); time_t mkgmtime(struct tm *t); time_t current_time(void); diff --git a/gpsbabel/util.c b/gpsbabel/util.c index 080b555e2..f0974d423 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -495,13 +495,11 @@ str_match(const char *str, const char *match) int case_ignore_str_match(const char *str, const char *match) { - char *s1, *s2, *c; + char *s1, *s2; int res; - s1 = xstrdup(str); - for (c = s1; *c; c++) *c = toupper(*c); - s2 = xstrdup(match); - for (c = s2; *c; c++) *c = toupper(*c); + s1 = strupper(xstrdup(str)); + s2 = strupper(xstrdup(match)); res = str_match(s1, s2); xfree(s1); xfree(s2); @@ -907,6 +905,33 @@ xstrrstr(const char *s1, const char *s2) return r; } +/* + * + */ +char * +strupper(char *src) +{ + char *c; + + for (c = src; *c; c++) { + *c = toupper(*c); + } + return src; +} + +/* + * + */ +char * +strlower(char *src) +{ + char *c; + + for (c = src; *c; c++) { + *c = tolower(*c); + } + return src; +} char * rot13( const char *s ) @@ -1103,12 +1128,8 @@ strip_nastyhtml(const char * in) char *lcstr, *lcp; sp = returnstr = xstrdup(in); - lcp = lcstr = xstrdup(in); + lcp = lcstr = strlower(xstrdup(in)); - while (*lcp) { - *lcp = tolower(*lcp); - lcp++; - } while (lcp = strstr(lcstr, "